/**
 * Created with CLion.
 * Description: 
 * User: cyber
 * Date: 2020-09-07
 * Time: 8:47
 */
#include <iostream>

using namespace std;

constexpr int square(int x)
{
    return x * x;
}

/**
 * @brief 一般构造函数的类
 */
class CX
{
private:
    int a;
    
    int b;

public:
    CX() = default;

    constexpr CX(int _a, int _b)
        : a(_a)
          , b(_b)
    { }
    
    constexpr int getA() /*const*/
    {
        return a;
    }

    constexpr int getB() /*const*/
    {
        return b;
    }

    constexpr int foo() /*const*/
    {
        return a - b;
    }
};

template<typename T>
constexpr T sum(T a,T b){
    return a + b;
}

int main()
{
    int dummy = 5;
    int array[square(dummy)];
    cout << sizeof(array) / sizeof(int) << endl;
    
    constexpr int i = sum(3,42);        //sum<int> 是constexpr
    std::string s = sum(std::string("hello"),std::string("world"));         //sum<std::string> 不是constexpr
    
    return 0;
}

